﻿#include "custom_data.h"
#include <iostream>
#include <thread>

using namespace boost::interprocess;

int main()
{
    // struct shm_remove {
    //     shm_remove() {
    //         shared_memory_object::remove("my_shared_memory");
    //     }
    //     ~shm_remove() {
    //         shared_memory_object::remove("my_shared_memory");
    //     }
    // } remover;

    managed_shared_memory segment(open_or_create, "my_shared_memory", 524288000);
    custom_data data;
    data.init(segment);
    std::string key = "aaaaaa";
    std::string data_str =
        "fdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjs"
        "dafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkas"
        "jfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjs"
        "afkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfd"
        "sfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdla"
        "sfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsa"
        "jfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjda"
        "skfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkds"
        "jfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjf"
        "dkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewk"
        "jfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfd"
        "sjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsda"
        "fdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjf"
        "jdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsaf"
        "kjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsf"
        "jkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasf"
        "jdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajf"
        "jewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdask"
        "fjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjf"
        "jsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdk"
        "asjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjf"
        "jsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsj"
        "fdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafd"
        "lasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjd"
        "sajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkj"
        "daskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjkdsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfjfdsjfdsfjk"
        "dsjfjsdafdlasfjdjfdkasjfjdsajfjewkjfjsafkjdaskfj";
    while (true)
    {
        data.set(key, data_str);
        // std::this_thread::sleep_for(std::chrono::seconds(1));
    }

    return 0;
}